﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;
using ModuleDALCore;

namespace DAL
{
	public class DOTKHAMDAO:DALBase
	{
		public DOTKHAMDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;

		public string SpName
		{
			get { return "SPDOTKHAM"; }
			set { _SpName = value; }
		}
		public DataTable GetListDOTKHAM(DOTKHAM dk)
		{
			dt = new DataTable();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 0));
				return dt;
			}
			catch { return null; }
		}
		public DataTable GetDUTOANDIEUTRIRPT(DOTKHAM dk)
		{
			dt = new DataTable();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 8));
				return dt;
			}
			catch { return null; }
		}
		public List<DOTKHAM> GetListDOTKHAMS(DOTKHAM dk)
		{
			dt = new DataTable();
			List<DOTKHAM> ds = new List<DOTKHAM>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 0));
				ds = (List<DOTKHAM>)ConvertDatatableToList.ConvertTo<DOTKHAM>(dt);
				return ds;
			}
			catch { return null; }
		}
		public List<DOTKHAM> GetListDOTKHAMMOI(DOTKHAM dk)
		{
			dt = new DataTable();
			List<DOTKHAM> ds = new List<DOTKHAM>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 4));
				ds = (List<DOTKHAM>)ConvertDatatableToList.ConvertTo<DOTKHAM>(dt);
				return ds;
			}
			catch { return null; }
		}
		public List<DOTKHAM> GetListDOTKHAMMOIDT(DOTKHAM dk)
		{
			dt = new DataTable();
			List<DOTKHAM> ds = new List<DOTKHAM>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 6));
				ds = (List<DOTKHAM>)ConvertDatatableToList.ConvertTo<DOTKHAM>(dt);
				return ds;
			}
			catch { return null; }
		}
		public DOTKHAM GETDOTKHAM(DOTKHAM dk)
		{
			dt = new DataTable();
			DOTKHAM ds = new DOTKHAM();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 5));
				ds = (DOTKHAM)ConvertDatatableToList.ConvertToObject<DOTKHAM>(dt);
				return ds;
			}
			catch { return null; }//throw new InvalidExpressionException("Msg1: Can't list BC"); }
		}
		public List<DOTKHAM> GETLISTDOTKHAMTHANHTOAN(DOTKHAM dk)
		{
			dt = new DataTable();
			List<DOTKHAM> ds = new List<DOTKHAM>();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(dk, null), ConvertClassToArray.GetValues(dk, 7));
				ds = (List<DOTKHAM>)ConvertDatatableToList.ConvertTo<DOTKHAM>(dt);
				return ds;
			}
			catch { return null; }
		}
	}
}